﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace postSale.forms
{
    public partial class processAssignList : processAssignEdit 
    {
        public processAssignList()
        {
            try
            {
                InitializeComponent();
                processCriteria.myTaskStatusList = this.myValidTaskStatusList;
                processCriteria.mySelectedTaskStatus = common.CommonStatus.New;
            }
            catch (Exception er)
            {
                this.ShowError(er);
            }
        }
        protected override bool FindData() { ShowFilter(); return true; }

        protected override void LoadData()
        {
            base.LoadData();
            DoFilter();
            ShowCustomer();   ShowWorkByName();
            this.ShowReccount(tasksSource.Count);
        }

        private void ShowFilter()
        {
            findBtn.Enabled = false;
            taskFilterPnl.Visible = true;
            dataGrid.Height = this.Height - taskFilterPnl.Height -
                              2 * (SystemInformation.CaptionHeight + SystemInformation.BorderSize.Height) - 7;
        }
        protected void DoFilter()
        {
            this.tasksSource.Filter = processCriteria.GetCriteria("", false);
            ShowWorkByName();
        }

        private void filterBtn_Click(object sender, EventArgs e)
        {
            try
            {
                DoFilter();
            }
            catch (Exception er)
            {
                this.ShowError(er);
            }
        }
        private void closeFilterBtn_Click(object sender, EventArgs e)
        {
            findBtn.Enabled = true;
            taskFilterPnl.Visible = false;
            dataGrid.Height = this.Height - 2 * (SystemInformation.CaptionHeight + SystemInformation.BorderSize.Height) - 9;
        }

        private void dataGrid_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            this.ShowError(e.Exception);
        }
    }
}
